package com.huaxiafinance.management.util;


import java.lang.reflect.Field;


/**
 * HEAD Created by xieWei on 2017/9/13.
 */
public class ReflexUtil
{
    /**
     * 判断实体类对象多少参数不是null
     *
     * @param bean
     * @param num
     * @return boolean
     * @throws IllegalAccessException
     */
    public static boolean chooseBean(Object bean, int num)
        throws IllegalAccessException
    {
        Class c = bean.getClass();
        Field[] fs = c.getDeclaredFields();
        int a = 0;
        for (Field f : fs)
        {
            f.setAccessible(true);
            Object o = f.get(bean);
            if (o != null)
            {
                a = a + 1;
            }
        }
        if (a < num)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
}
